<template>
  <div class="container">
    <el-card class="qbCard" shadow="hover">
    <div slot="header" class="header">
        <span>{{"题库名称:"+qbItem.qb_name}}</span>
      </div>
     <div class="body">
        <div class="description">{{qbItem.qb_description}}</div>
        <div class="create_date">{{"创建者："+ (qbItem.user?qbItem.user.usernickname:"无")}}</div>
       <el-button  type="text" @click="toWhere">查看</el-button>
       <el-button  type="text"  @click="deleteqb">删除</el-button>
      </div>

    </el-card>
  </div>
</template>

<script>
// import axiosinstance from "@/util/http.js";

import axiosinstance from "@/util/http";

export default {

  name: "PaperDetail",
   data() {
    return {
      formLabelWidth: "100px",
      user: {},
      qbItems: [], //获取到的服务器数据
      qbform: {
        username: "",
        qb_id: "",
      },
    };
  },
  props: {
    qbItem: {
      type: Object,
      default: function () {
        return {
        };
      },
    },
  },
  methods: {
    toWhere() {
      this.$emit("aSignal", this.qbItem.qb_id, this.qbItem.qb_name);
      this.$router.push({
        path: "QuestionBaseDetail",
        query: {
          qb_id: this.qbItem.qb_id,
        },
      });
      console.log(this.$route.query);
    },
    async deleteqb() {
      this.user = this.$store.getters.getuser;
      console.log("efa", this.user);
      this.qb_id=this.qbform.qb_id;
      console.log("afafqa", this.qb_id);

      let res = await axiosinstance({
        url: '/questionbase/deletequestionbase',
        method: 'post',
        data:{
          username: this.user.username,
          qb_id: this.qbItem.qb_id,
        }
      });
      if(res){
        this.$message({
          showClose: true,
          message: '删除成功',
          type: 'success'
        });
      }else{
        this.$message({
          showClose: true,
          message: '删除失败',
          type: 'err'
        });
      }

      this.$emit("deleteqb");

    },
  },
};
</script>

<style scoped lang="less">
.container{
    margin:0;
    height:inherit;
    width:100%;
    padding:0;
    .qbCard{
      height:inherit;
      border:2px solid rgb(255, 255, 255);
      border-radius:35px;
      //transition: all 250ms cubic-bezier(.02, .01, .47, 1);
      transition-delay: 0.04s;
      transition-duration:0.7s;
      &:hover{
        transform: translate(0,-5px);
        border-radius:15px;
        transition-delay: 0.13s;
        transition-duration:0.7s;
      }

      .header{

      }
      .body{
        .description{
          overflow:hidden;
          display:block;
          height:100%;
          width:100%;

        }
        .create_date{

        }
      }
    }

  }
</style>